package net.cassandraview.db;

import org.apache.cassandra.thrift.CfDef;
import org.apache.cassandra.thrift.KsDef;

import java.util.Map;

/**
 * Connection to database for performing management tasks, such as clomn family creation, index creation/droping etc.
 * 
 * User: nagakhl
 * Date: 22.01.12
 * Time: 15:30
 */
public interface ManagementConnection extends Connection {

    /**
     * Create empty keyspace with default strategy (SimpleStrategy) and default replication factor (1)
     * 
     * @param keyspaceName name of keyspace to create
     * @return Schema version ID or null in case of some error
     */
    public String createKeyspace(String keyspaceName);

    /**
     * Create empty keyspace wuth strategy and options specified
     *
     * @param keyspaceName name of keyspace to create
     * @param strategyName fully qualified class name for strategy
     * @param options options that are needed for given strategy
     * @return Schema version ID or null in case of some error
     */
    public String createKeyspace(String keyspaceName, String strategyName, Map<String, String> options);

    /**
     * Get keyspace definition.
     * 
     * @param keyspaceName Name of keyspace to retrieve data about.
     * @return KsDef object with keyspace data or null if no such keyspace exists.
     */
    public KsDef getKeyspaceInfo(String keyspaceName);
    
    /**
     * Drop keyspace with given name
     *
     * @param keyspaceName name of keyspace to drop
     * @return Schema version ID or null in case of some error
     */
    public String dropKeyspace(String keyspaceName);

    /**
     * Creates column family in default keyspace
     *
     * @param name name of column family ti create
     * @param isSuper should column family be of type Super
     * @return Schema version ID or null in case of some error
     */
    public String createColumnFamily(String name, boolean isSuper);

    /**
     * Drop column family with given name from default keyspace
     *
     * @param name name of column family to drop
     * @return Schema version ID or null in case of some error
     */
    public String dropColumnFamily(String name);

    /**
     * Get properties of column family.
     *
     * @param name Name of column family to retrieve data about
     * @return CfDef with column family properties or null if no such column family exists
     */
    public CfDef getColumnFamilyInfo(String name);
    
    public String createIndex(String columnFamily, String fieldName);

    public String dropIndex(String columnFamily, String fieldName);
    
}
